<script type="text/JavaScript">
$(document).ready(function()
{
	//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
	$("#firstpane p.menu_head").click(function()
    {
		$(this).css({backgroundImage:"url(../images/mn2.png)"}).next("div.menu_body").slideToggle(190).siblings("div.menu_body").slideUp("slow");
       	$(this).siblings();
	});
	
});
//-->
</script>
<div id="sidebar">
	<table width="100%" cellpadding="0" cellspacing="0" class="c_l_menu" border="0">
		<tr>
			<td>
				<div id="firstpane">
				<?
				global $db;
				//cat san pham
				include_once(DIR_MODEL."md_cat_san_pham.class.php");
				$objCatSanpham = new MD_CatSanpham($db);
				$arrayData_CatSanpham =  array();
				$arrayData_CatSanpham0 = $objCatSanpham->getByWhere("*","hien_thi=1 and parent_id=0","thu_tu asc");
				
				//san pham
				include_once(DIR_MODEL."md_san_pham.class.php");
				$objSanpham = new MD_Sanpham($db);
				$arrayData_CatSanpham = array();
				$arrayData_CatSanpham_Temp = array();
				$id_loai_sp = CM_getParameter("id_loai_sp");
				$parent_id = CM_getParameter("parent_id");
				//hien thi du lieu
				$tong = sizeof($arrayData_CatSanpham0);
				foreach($arrayData_CatSanpham0 as $row0 ){
				$arrayData_CatSanpham = $objCatSanpham->getByWhere("id,ten_loai_sp,parent_id","parent_id =".$row0['id']."","thu_tu asc");
				?>
					<p class="menu_head">						
						<img src="../admin/images/images_upload/img_con_sp/<?=$row0['icon_loai_sp']?>" style="float:left; width:20px; padding-top:5px;" />
						<?
							if(!empty($arrayData_CatSanpham)){
						?>
						<a style="cursor:pointer; "><?=$row0['ten_loai_sp']?></a>
						<?
							}else{
						?>
						<a href="?modul=sanpham&action=List&id_loai_sp=<?=$row0['id']?>"><?=$row0['ten_loai_sp']?></a>
						<?
							}
						?>
					</p><!-- menu_head -->
				<?
					if(!empty($arrayData_CatSanpham)){
					
				?>
				
				<div style=" <? if(($modul == "sanpham") && (($id_loai_sp == $row0['id']) || ($parent_id == $row0['id']))){?> display:block; <? }else{?> display:none; <? }?>" class="menu_body">
				<?
						foreach($arrayData_CatSanpham as $row){
						$arrayData = $objSanpham -> getByWhere("*","id_loai_sp = ".$row['id']. " AND hien_thi = 1","");
						$tongSp = count($arrayData);
				?>
						<div style=" padding-left:35px;">
						<hr style="width:90%; border: 1px solid #FF0000;"/>
						</div>
						<a  href="?modul=sanpham&action=List&id_loai_sp=<?=$row['id']?>&parent_id=<?=$row['parent_id']?>" 
							<? if($modul == "sanpham" & $id_loai_sp == $row['id'] ){?>  style="color:#ffb400; "<? }?> class="fly">
						
						<img src="../images/icon_submenu.gif" style="float:left; padding-left:25px; padding-right:5px; padding-top:3px; ">
						<?=$row['ten_loai_sp']?>&nbsp; <span style="color:#0000FB; ">(<?=$tongSp?>)</span>
						
						</a>
				<?
						}//end foreach arrayData_CatSanpham
				?>
				</div>
				<?
					}//end if arrayData_CatSanpham
			
					$tong--;
					if ($tong){ 
				?>
				<div style="padding-left:35px;">
				<hr style="width:90%; border: 1px solid #FF0000;"/>
				</div>
				<?
					}//end if $tong
				}//end foreach arrayData_CatSanpham0
				?>
				</div><!-- firstpane -->
			</td>
		</tr>
	</table>
</div><!-- sidebar -->